package com.atguigu.Servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 类说明：
 *
 * @author ChenCheng
 * @ClassName BaseServlet
 * @create 2023-02-05 18:02
 * @Version 1.0
 */
public abstract class BaseServlet extends HttpServlet {


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String action = request.getParameter("action");
        try {
            this.getClass().getDeclaredMethod(action, HttpServletRequest.class, HttpServletResponse.class)
                    .invoke(this, request, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
